package xusage.cumulus.deployer.decider;

import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URLConnection;

import org.springframework.core.io.Resource;

import xusage.cumulus.deployer.AbstractDeployPathDecider;

public class JarDeployPathDecider extends AbstractDeployPathDecider {

	@Override
	public String decide(Resource resource) throws IOException {
		String resultPath = null;
		URLConnection conn = resource.getURL().openConnection();					
		if (conn instanceof JarURLConnection) {
			JarURLConnection jarUrlConn = (JarURLConnection)conn;
			resultPath = context.getRealPath("/") + jarUrlConn.getJarEntry().getName();
		}
		return resultPath;
	}

}
